﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bootstrap.MVC.Common;
using Bootstrap.MVC.Utils;

namespace Bootstrap.MVC.Widgets
{
    public class DropDownMenuBuilder : WidgetBuilderBase<IDropDownMenuModel, 
                                           DropDownMenuBuilder, 
                                           DropDownMenuHtmlGenerator,
                                           DropDownMenuScriptGenerator>
    {
        public DropDownMenuBuilder(IDropDownMenuModel model,
                             DropDownMenuHtmlGenerator htmlGenerator,
                             DropDownMenuScriptGenerator scriptGenerator )
            : base(model, htmlGenerator, scriptGenerator) { }


        public DropDownMenuBuilder(IDropDownMenuModel model) : base(model) { }


        #region Public Methods

        // TODO- must be moved to base
        public DropDownMenuBuilder DropUp(bool dropup = true)
        {
            Model.DropUp = dropup;
            return this;
        }


        //TODO- must be moved to base
        //public ButtonDropDownBuilder Size(ButtonSize size)
        //{
        //    Guard.IsNotNull(size, "size");
        //    Model.Size = size;
        //    return this;
        //}

        public DropDownMenuBuilder Items(Action<DropDownItemFactory> itemAction)
        {
            Guard.IsNotNull(itemAction, "itemAction");

            var eventFactory = new DropDownItemFactory(Model);
            itemAction(eventFactory);

            return this;
        }

        public DropDownMenuBuilder Bind(IEnumerable<IDropDownItemModel> items)
        {
            Guard.IsNotNull(items, "items");

            Model.Items = items.ToList();

            return this;
        }

        public DropDownMenuBuilder AlignTo(LeftOrRight align)
        {
            Model.Align = align;

            return this;
        }

        #endregion Public Methods


    }
}
